package Mem;

public class OriginatorChess {
    private MementoChess memchess;
    public OriginatorChess(MementoChess mem)
    {
        this.memchess = mem;
    }

    public void SetX(int x)
    {
        memchess.setX(x);    //set the value of the originator's x-coordinate to the value of the memento's x
    }

    public void SetY(int y) 	//set the value of the originator's y-coordinate to the value of the memento's y
    {
        memchess.setY(y);
    }

    public MementoChess SavetoMemento()
    {
        return new MementoChess(memchess.getLabel());

    }

    public void Restore(MementoChess mem)
    {
        this.memchess.setLabel(mem.getLabel());  //set the originator's left-coordinate to the value of the memento
        this.memchess.setX(mem.getX());          //set the originator's left-coordinate to the value of the mement
        this.memchess.setY(mem.getY());          //set the originator's left-coordinate to the value of the mement
    }

    public void Show()
    {
        System.out.println("ǰ״̬"+"x: " + memchess.getX() + " y: " + memchess.getY() + " label: " + memchess.getLabel());
    }

}
